#ifndef ENGINE_SHADERCOMPILE_H
#define ENGINE_SHADERCOMPILE_H

class ShaderCompileManager
{
public:
	ShaderCompileManager();
	~ShaderCompileManager();

	ID3D11VertexShader* CompileVSShader(const char* pShaderFileName, const char* pShaderMainFun);
	ID3D11PixelShader*  CompilePSShader(const char* pShaderFileName, const char* pShaderMainFun);

	ID3D10Blob* FindVSCodeBlob(const char* pShaderFileName, const char* pShaderMainFun);
	ID3D10Blob* FindPSCodeBlob(const char* pShaderFileName, const char* pShaderMainFun);

private:
	unsigned int _ComputeShaderCacheKey(const char* pShaderFileName, const char* pShaderMainFun);
	ID3D11VertexShader* _FindVSShaderInCache(unsigned int ShaderCacheKey);
	ID3D11PixelShader* _FindPSShaderInCache(unsigned int ShaderCacheKey);
	string _ReadShaderToString(const char* pShaderFileName);

private:
	// Shader Class Cache, Key = $ShaderFileName$ShaderMainFun
	map<unsigned int, ID3D11VertexShader*>	m_mapVSCache;
	map<unsigned int, ID3D10Blob*>	m_mapVSCodeBlob;
	map<unsigned int, ID3D11PixelShader*>	m_mapPSCache;
	map<unsigned int, ID3D10Blob*>	m_mapPSCodeBlob;
};

extern ShaderCompileManager GShaderCompileManager;

#endif